package 对象之多态.多态的步骤.demo02;


public class text {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.setName("史迪奇");
        a.eat();
    }
}

class Animal {
    private String name;

    public Animal() {
    }

    public Animal(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void eat() {
        System.out.println("吃饭");

    }

}

class Dog extends Animal {
    public void eat() {
        System.out.println(getName() + "吃骨头");

    }

}